#include "head.h"

static struct list2_teachwork view2_teachwork;
static struct list1_teacherwork find_l1;
static GtkTreeIter edit_teacherinfo_iter;
static struct edit e1;
static struct edit e2;
static struct mydelete md1;
static struct mydelete md2;
static struct myinsert mi1;
static struct myinsert mi2;
static struct edit e0;
static struct mydelete md0;
static struct myinsert mi0;

//密码确认函数
void pass_check(GtkWidget *button,struct password* data)
{

    GtkWidget *messagedialog;
    if((strcmp(data->pre_password,gtk_entry_get_text(GTK_ENTRY(data->entry1_1))))==0)
    {
        gtk_widget_destroy(data->window1);
        gtk_widget_show(data->window);
        gtk_main();
    }
    else
    {
        messagedialog=gtk_message_dialog_new(GTK_WINDOW(data->window1),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"密码错误");
        if((gtk_dialog_run(GTK_DIALOG(messagedialog))==GTK_RESPONSE_CLOSE))
        {
            gtk_widget_destroy(data->window1);
            gtk_main_quit();
        }
        else if((gtk_dialog_run(GTK_DIALOG(messagedialog))==GTK_RESPONSE_DELETE_EVENT))
        {
            gtk_widget_destroy(data->window1);
            gtk_main_quit();
        }
    }
}

//关于对话框
void about_dialog(GtkWidget*dialog,gpointer data)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *label;
    GtkWidget *image;
    GtkWidget *button;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"关于");
    gtk_window_resize(GTK_WINDOW(window),150,100);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);
    image=gtk_image_new_from_stock(GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
    gtk_box_pack_start(GTK_BOX(vbox),image,FALSE,FALSE,5);
    gtk_widget_show(image);
    label=gtk_label_new("教师信息管理系统");
    gtk_box_pack_start(GTK_BOX(vbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    label=gtk_label_new("学号：U201314861\n姓名：韦雨成");
    gtk_box_pack_start(GTK_BOX(vbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    button=gtk_button_new_from_stock(GTK_STOCK_OK);
    g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,5);
    gtk_widget_show(button);
    gtk_widget_show(vbox);
    gtk_widget_show(window);
}

//破坏组件
void destroy_widget(GtkWidget*widget,GtkWidget*widget2)
{
    gtk_widget_destroy(widget2);
}

//修改密码
void edit_password(GtkWidget*menuitem,struct password*data)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *button;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"修改密码");
    gtk_window_resize(GTK_WINDOW(window),100,100);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("旧密码:");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),FALSE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("新密码:");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),FALSE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    data->window=window;
    data->entry1_1=entry;
    data->entry1=entry1;
    button=gtk_button_new_from_stock(GTK_STOCK_OK);
    g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(confirm_password),data);
    gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,5);
    gtk_widget_show(button);
    gtk_widget_show(vbox);
}

//密码确认
void confirm_password(GtkWidget*button,struct password*data)
{
    GtkWidget *messagedialog;
    if((strcmp(data->pre_password,gtk_entry_get_text(GTK_ENTRY(data->entry1_1))))==0)
    {
        strcpy(data->pre_password,gtk_entry_get_text(GTK_ENTRY(data->entry1)));
        data->fp=fopen(data->filename,"w");
        fprintf(data->fp,"%s",data->pre_password);
        fclose(data->fp);
        gtk_widget_destroy(data->window);
    }
    else
    {
        messagedialog=gtk_message_dialog_new(GTK_WINDOW(data->window),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"原密码错误");
        if((gtk_dialog_run(GTK_DIALOG(messagedialog))==GTK_RESPONSE_CLOSE))
        {
            gtk_widget_destroy(data->window);
        }
        else if((gtk_dialog_run(GTK_DIALOG(messagedialog))==GTK_RESPONSE_DELETE_EVENT))
        {
            gtk_widget_destroy(data->window);
        }
    }
}

//添加数据到教师基本信息树视图
void list_data_add1(GtkTreeModel*liststore,struct teacherinfo*p)
{
    GtkTreeIter iter;
    gtk_list_store_append(GTK_LIST_STORE(liststore), &iter);
    gtk_list_store_set(GTK_LIST_STORE(liststore),&iter,ID1,p->id,NAME1,p->name,WORK1,p->workplace,DUTY1,p->duty,-1);
}

//添加数据到教师工作量树视图
void list_data_add2(GtkTreeModel*liststore,struct teacherwork*p)
{
    GtkTreeIter iter;
    gtk_list_store_append(GTK_LIST_STORE(liststore), &iter);
    gtk_list_store_set(GTK_LIST_STORE(liststore),&iter,ID2,p->id,YEAR2,p->year,KEYAN2,p->keyan,BISHE2,p->bishe,SHUO_BO2,p->shuobo,TOTAL2,p->zongfen,-1);
}

//添加数据到教学工作树视图
void list_data_add3(GtkTreeModel*liststore,struct teachwork*p)
{
    GtkTreeIter iter;
    gtk_list_store_append(GTK_LIST_STORE(liststore), &iter);
    gtk_list_store_set(GTK_LIST_STORE(liststore),&iter,ID3,p->id,YEAR3,p->year,KECHENG3,p->kecheng,SHOUKEXUESHI3,p->shouke,SHIYANXUESHI3,p->shiyan,XUESHENGRENSHU3,p->renshu,BANJI3,p->banji,-1);
}

//创建教师基本信息module
GtkTreeModel* creat_module1(void)
{
    GtkListStore  *store;
    store = gtk_list_store_new (N1,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
    return GTK_TREE_MODEL(store);
}

//创建教师工作量module
GtkTreeModel* creat_module2(void)
{
    GtkListStore  *store;
    store = gtk_list_store_new (N2,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
    return GTK_TREE_MODEL(store);
}

//创建教学工作module
GtkTreeModel* creat_module3(void)
{
    GtkListStore  *store;
    store = gtk_list_store_new (N3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
    return GTK_TREE_MODEL(store);
}

//添加column到教师基本信息
void arrange_treelist1(GtkWidget*treelist)
{
    GtkCellRenderer* renderer;

    // col 1
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(treelist), -1, "编号ID          ", renderer, "text", ID1, NULL);

    // col 2
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(treelist), -1, "姓名          ", renderer, "text", NAME1, NULL);

    // col 3
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(treelist), -1, "单位          ", renderer, "text", WORK1, NULL);

    // col4
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"职称",renderer,"text",DUTY1,NULL);
}

//添加column到教师工作量
void arrange_treelist2(GtkWidget*treelist)
{
    GtkCellRenderer* renderer;

    // col 1
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist), -1, "编号ID     ", renderer, "text", ID2, NULL);

    // col 2
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist), -1, "年份     ", renderer, "text", YEAR2, NULL);

    // col 3
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist), -1, "科研工作量     ", renderer, "text", KEYAN2, NULL);

    // col 4
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"指导毕设     ",renderer,"text",BISHE2,NULL);

    // col 5
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"指导硕/博士     ",renderer,"text",SHUO_BO2,NULL);

    // col 6
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"总分",renderer,"text",TOTAL2,NULL);
}

//添加column到教学工作
void arrange_treelist3(GtkWidget*treelist)
{
    GtkCellRenderer* renderer;

    // col 1
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist), -1, "编号ID     ", renderer, "text", ID3, NULL);

    // col 2
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist), -1, "年份     ", renderer, "text", YEAR3, NULL);

    // col 3
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist), -1, "课程名     ", renderer, "text", KECHENG3, NULL);

    // col 4
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"授课学时     ",renderer,"text",SHOUKEXUESHI3,NULL);

    // col 5
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"实验学时     ",renderer,"text",SHIYANXUESHI3,NULL);

    // col 6
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"学生人数     ",renderer,"text",XUESHENGRENSHU3,NULL);

    // col 7
    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treelist),-1,"班级     ",renderer,"text",BANJI3,NULL);
}

//新建功能回调函数
void click_new(GtkWidget*menu,struct tree_list1*t)
{
    gtk_widget_show(t->list1);
    gtk_widget_set_sensitive(t->button1,TRUE);
}


//新增1的回调函数
void new_add1(GtkWidget*button,struct list1_new_add*l)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *button1;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师基本信息");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("姓名    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("单位    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("职称    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);


    l->entry=entry;
    l->entry1=entry1;
    l->entry2=entry2;
    l->entry3=entry3;
    l->window=window;
    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(new_confirm1),l);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);

}

void new_confirm1(GtkWidget*button,struct list1_new_add*l)
{
    struct teacherinfo*p;
    struct teacherinfo*hp;

    p=(struct teacherinfo*)malloc(sizeof(struct teacherinfo));
    strcpy(p->id,gtk_entry_get_text(GTK_ENTRY(l->entry)));
    strcpy(p->name,gtk_entry_get_text(GTK_ENTRY(l->entry1)));
    strcpy(p->workplace,gtk_entry_get_text(GTK_ENTRY(l->entry2)));
    strcpy(p->duty,gtk_entry_get_text(GTK_ENTRY(l->entry3)));
    p->p1=NULL;
    p->p2=NULL;

    if(*(l->head)==NULL)
        *(l->head)=p;
    else
    {
        for(hp=(*(l->head)); hp->p2!=NULL; hp=hp->p2);
        hp->p2=p;
    }

    list_data_add1(l->module1,p);
    gtk_widget_destroy(l->window);
}

void teacher_work(GtkTreeSelection*selection,GtkWidget*button)
{
    gtk_widget_set_sensitive(button,TRUE);
}

//树视图1的教师工作量回调函数
void list1_teacher_work(GtkWidget*button,struct list1_teacherwork*l)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *view;
    GtkTreeModel *store;
    GtkWidget *button1;
    GtkWidget *button2;
    GtkWidget *h_button3;
    GtkWidget *h_button4;
    GtkWidget *h_button5;
    GtkTreeSelection*select;
    GtkTreeIter iter;
    GtkTreeModel *model;
    GtkWidget *scrollwindow;
    gchar *id;

    struct teacherwork**hp;
    struct teacherinfo*h1=head;

    if (gtk_tree_selection_get_selected (l->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID1, &id, -1);

    while(strcmp(h1->id,id))
        h1=h1->p2;
    hp=&(h1->p1);
    strcpy(l->id,id);
    strcpy(mi1.id,id);
    g_free(id);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师工作量");
    gtk_window_resize(GTK_WINDOW(window),508,410);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    scrollwindow=gtk_scrolled_window_new(NULL,NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(GTK_BOX(vbox),scrollwindow,TRUE,TRUE,0);
    gtk_widget_show(scrollwindow);

    view=gtk_tree_view_new();
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwindow),view);
    arrange_treelist2(view);
    store=creat_module2();
    gtk_tree_view_set_model(GTK_TREE_VIEW(view),store);
    select = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
    gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
    gtk_widget_show(view);
    l->module2=store;
    view2_teachwork.select=select;
    e1.select=select;
    e1.module=store;
    e1.module2=NULL;
    md1.select=select;
    md1.module=store;
    md1.module2=NULL;
    mi1.module1=store;
    mi1.select=select;
    mi1.module2=NULL;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_end(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
    button1=gtk_button_new_with_label("    新增    ");
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    gtk_widget_show(button1);

    button2=gtk_button_new_with_label("  教学工作  ");
    gtk_box_pack_start(GTK_BOX(hbox),button2,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button2),"clicked",G_CALLBACK(list2_teach_work),&view2_teachwork);
    gtk_widget_set_sensitive(button2,FALSE);
    gtk_widget_show(button2);

    //修改按钮
    h_button3=gtk_button_new_with_label("     修改     ");
    gtk_box_pack_start(GTK_BOX(hbox),h_button3,FALSE,FALSE,5);
    gtk_widget_set_sensitive(h_button3,FALSE);
    g_signal_connect(G_OBJECT(h_button3),"clicked",G_CALLBACK(edit_teacherwork),&e1);
    gtk_widget_show(h_button3);
    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),h_button3);

    //删除按钮
    h_button4=gtk_button_new_with_label("     删除     ");
    gtk_box_pack_start(GTK_BOX(hbox),h_button4,FALSE,FALSE,5);
    gtk_widget_set_sensitive(h_button4,FALSE);
    g_signal_connect(G_OBJECT(h_button4),"clicked",G_CALLBACK(delete_teacherwork),&md1);
    gtk_widget_show(h_button4);
    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),h_button4);

    //插入按钮
    h_button5=gtk_button_new_with_label("     插入     ");
    gtk_box_pack_start(GTK_BOX(hbox),h_button5,FALSE,FALSE,5);
    gtk_widget_set_sensitive(h_button5,FALSE);
    g_signal_connect(G_OBJECT(h_button5),"clicked",G_CALLBACK(insert_teacherwork),&mi1);
    gtk_widget_show(h_button5);
    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),h_button5);
    gtk_widget_show(hbox);
    gtk_widget_show(vbox);

    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teach_work),button2);

    if((*hp)!=NULL)
    {
        while((*hp)!=NULL)
        {
            list_data_add2(store,(*hp));
            hp=&((*hp)->p2);
        }
    }

    l->head2=hp;
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(new_add2),l);
    gtk_widget_show(window);
}

//树视图2新增的回调函数
void new_add2(GtkWidget*button,struct list1_teacherwork*l)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *button1;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师工作量");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID              :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),l->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份                 :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("科研工作量(万元):");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("指导毕设(人)      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("指导硕/博(人)     :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry4=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry4),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry4,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry4),TRUE);
    gtk_widget_show(entry4);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("总分(分)            :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry5=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry5),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry5,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry5),TRUE);
    gtk_widget_show(entry5);
    gtk_widget_show(hbox);

    l->entry=entry;
    l->entry1=entry1;
    l->entry2=entry2;
    l->entry3=entry3;
    l->entry4=entry4;
    l->entry5=entry5;
    l->window=window;
    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(new_confirm2),l);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);
}

//树视图2新增确认的回调函数
void new_confirm2(GtkWidget*button,struct list1_teacherwork*l)
{
    struct teacherwork*p;
    struct teacherwork*hp;

    p=(struct teacherwork*)malloc(sizeof(struct teacherwork));
    strcpy(p->id,gtk_entry_get_text(GTK_ENTRY(l->entry)));
    strcpy(p->year,gtk_entry_get_text(GTK_ENTRY(l->entry1)));
    strcpy(p->keyan,gtk_entry_get_text(GTK_ENTRY(l->entry2)));
    strcpy(p->bishe,gtk_entry_get_text(GTK_ENTRY(l->entry3)));
    strcpy(p->shuobo,gtk_entry_get_text(GTK_ENTRY(l->entry4)));
    strcpy(p->zongfen,gtk_entry_get_text(GTK_ENTRY(l->entry5)));
    p->p1=NULL;
    p->p2=NULL;

    if(*(l->head2)==NULL)
        *(l->head2)=p;
    else
    {
        for(hp=(*(l->head2)); hp->p2!=NULL; hp=hp->p2);
        hp->p2=p;
    }

    list_data_add2(l->module2,p);
    gtk_widget_destroy(l->window);
}

void teach_work(GtkTreeSelection*selection,GtkWidget*button)
{
    gtk_widget_set_sensitive(button,TRUE);
}


//树视图2教学工作回调函数
void list2_teach_work(GtkWidget*button,struct list2_teachwork*l)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *view;
    GtkTreeModel *store;
    GtkWidget *button1;
    GtkWidget *h_button3;
    GtkWidget *h_button4;
    GtkWidget *h_button5;
    GtkTreeIter iter;
    GtkTreeModel *model;
    GtkTreeSelection*select;
    GtkWidget *scrollwindow;
    gchar *id;
    gchar*year;


    struct teacherwork*h2;
    struct teachwork**headp;
    struct teacherinfo*h1=head;

    if (gtk_tree_selection_get_selected (l->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID2, &id, -1);
    while(strcmp(h1->id,id))
        h1=h1->p2;
    h2=h1->p1;

    if (gtk_tree_selection_get_selected (l->select, &model, &iter))
        gtk_tree_model_get (model, &iter, YEAR2, &year, -1);
    while(strcmp(h2->year,year))
        h2=h2->p2;
    headp=&(h2->p1);
    l->head3=headp;
    strcpy(l->id,id);
    strcpy(l->year,year);
    strcpy(mi2.id,id);
    strcpy(mi2.year,year);
    g_free(id);
    g_free(year);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教学工作");
    gtk_window_resize(GTK_WINDOW(window),508,410);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    scrollwindow=gtk_scrolled_window_new(NULL,NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(GTK_BOX(vbox),scrollwindow,TRUE,TRUE,0);
    gtk_widget_show(scrollwindow);

    view=gtk_tree_view_new();
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwindow),view);
    arrange_treelist3(view);
    store=creat_module3();
    gtk_tree_view_set_model(GTK_TREE_VIEW(view),store);
    select = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
    gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
    gtk_widget_show(view);
    l->module=store;
    e2.select=select;
    e2.module=store;
    e2.module2=NULL;
    md2.module=store;
    md2.select=select;
    md2.module2=NULL;
    mi2.module1=store;
    mi2.select=select;
    mi2.module2=NULL;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_end(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
    button1=gtk_button_new_with_label("    新增    ");
    l->button=button1;
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    gtk_widget_show(button1);

    //修改按钮
    h_button3=gtk_button_new_with_label("     修改     ");
    gtk_box_pack_start(GTK_BOX(hbox),h_button3,FALSE,FALSE,5);
    gtk_widget_set_sensitive(h_button3,FALSE);
    gtk_widget_show(h_button3);
    g_signal_connect(G_OBJECT(h_button3),"clicked",G_CALLBACK(edit_teachwork),&e2);
    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),h_button3);

    //删除按钮
    h_button4=gtk_button_new_with_label("     删除     ");
    gtk_box_pack_start(GTK_BOX(hbox),h_button4,FALSE,FALSE,5);
    gtk_widget_set_sensitive(h_button4,FALSE);
    g_signal_connect(G_OBJECT(h_button4),"clicked",G_CALLBACK(delete_teachwork),&md2);
    gtk_widget_show(h_button4);
    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),h_button4);

    //插入按钮
    h_button5=gtk_button_new_with_label("     插入     ");
    gtk_box_pack_start(GTK_BOX(hbox),h_button5,FALSE,FALSE,5);
    gtk_widget_set_sensitive(h_button5,FALSE);
    g_signal_connect(G_OBJECT(h_button5),"clicked",G_CALLBACK(insert_teachwork),&mi2);
    gtk_widget_show(h_button5);
    g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),h_button5);
    gtk_widget_show(hbox);

    if((*headp)!=NULL)
    {
        while((*headp)!=NULL)
        {
            list_data_add3(store,(*headp));
            headp=&((*headp)->p1);
        }
    }

    l->head3=headp;
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(new_add3),l);
    gtk_widget_show(vbox);
    gtk_widget_show(window);
}

//树视图3新增的回调函数
void new_add3(GtkWidget*button,struct list2_teachwork*lt)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *entry6;
    GtkWidget *button1;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教学工作");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);


    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),lt->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份         :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry1),lt->year);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("课程名      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("授课学时   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("实验学时   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry4=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry4),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry4,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry4),TRUE);
    gtk_widget_show(entry4);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("学生人数   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry5=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry5),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry5,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry5),TRUE);
    gtk_widget_show(entry5);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("班级         :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry6=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry6),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry6,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry6),TRUE);
    gtk_widget_show(entry6);
    gtk_widget_show(hbox);

    lt->entry=entry;
    lt->entry1=entry1;
    lt->entry2=entry2;
    lt->entry3=entry3;
    lt->entry4=entry4;
    lt->entry5=entry5;
    lt->entry6=entry6;
    lt->window=window;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(new_confirm3),lt);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);

}

//树视图3新增确认的回调函数
void new_confirm3(GtkWidget*button,struct list2_teachwork*l)
{
    struct teachwork*p,*hp;

    p=(struct teachwork*)malloc(sizeof(struct teachwork));
    strcpy(p->id,gtk_entry_get_text(GTK_ENTRY(l->entry)));
    strcpy(p->year,gtk_entry_get_text(GTK_ENTRY(l->entry1)));
    strcpy(p->kecheng,gtk_entry_get_text(GTK_ENTRY(l->entry2)));
    strcpy(p->shouke,gtk_entry_get_text(GTK_ENTRY(l->entry3)));
    strcpy(p->shiyan,gtk_entry_get_text(GTK_ENTRY(l->entry4)));
    strcpy(p->renshu,gtk_entry_get_text(GTK_ENTRY(l->entry5)));
    strcpy(p->banji,gtk_entry_get_text(GTK_ENTRY(l->entry6)));
    p->p1=NULL;
    if(*(l->head3)==NULL)
        *(l->head3)=p;
    else
    {
        hp=(*(l->head3));
        while(hp->p1!=NULL)
            hp=hp->p1;
        hp->p1=p;
    }

    list_data_add3(l->module,p);
    gtk_widget_destroy(l->window);
}

//保存文件功能
void save_file(GtkWidget*menu,struct file*s)
{
    GtkWidget *dialog;
    gint flag;
    char *filename;

    dialog = gtk_file_chooser_dialog_new ("保存文件",GTK_WINDOW(s->window),GTK_FILE_CHOOSER_ACTION_SAVE,GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,NULL);
    g_signal_connect(G_OBJECT(dialog),"destroy",G_CALLBACK(destroy_widget),dialog);
    gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
    flag=gtk_dialog_run(GTK_DIALOG (dialog));
    if (flag == GTK_RESPONSE_ACCEPT)
    {
        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        s->teacherinfo_file=(char*)malloc(strlen(filename)+1);
        strcpy(s->teacherinfo_file,filename);
        s->teacherwork_file=(char*)malloc(strlen(filename)+5);
        strcpy(s->teacherwork_file,filename);
        strcat(s->teacherwork_file,"work");
        s->teachwork_file=(char*)malloc(strlen(filename)+10);
        strcpy(s->teachwork_file,filename);
        strcat(s->teachwork_file,"workteach");
        save_to_file(s);
        g_free (filename);
        gtk_widget_destroy(dialog);
    }
    else if(flag == GTK_RESPONSE_CANCEL)
        gtk_widget_destroy(dialog);

}

//保存文件
void save_to_file(struct file*s)
{
    FILE*out1,*out2,*out3;
    struct teacherinfo*hp1=head;
    struct teacherwork*hp2;
    struct teachwork*hp3;

    if((out1=fopen(s->teacherinfo_file,"wb"))==NULL)
        exit(-1);
    if((out2=fopen(s->teacherwork_file,"wb"))==NULL)
        exit(-1);
    if((out3=fopen(s->teachwork_file,"wb"))==NULL)
        exit(-1);
    while(hp1!=NULL)
    {
        fwrite(hp1,sizeof(struct teacherinfo),1,out1);
        hp2=hp1->p1;
        while(hp2!=NULL)
        {
            fwrite(hp2,sizeof(struct teacherwork),1,out2);
            hp3=hp2->p1;
            while(hp3!=NULL)
            {
                fwrite(hp3,sizeof(struct teachwork),1,out3);
                hp3=hp3->p1;
            }
            hp2=hp2->p2;
        }
        hp1=hp1->p2;
    }
    fclose(out1);
    fclose(out2);
    fclose(out3);

    free(s->teacherinfo_file);
    free(s->teacherwork_file);
    free(s->teachwork_file);
}

//打开文件功能
void open_files(GtkWidget*menu,struct file*s)
{
    GtkWidget*dialog;
    gint flag;
    char*filename;
    char*temp;

    dialog = gtk_file_chooser_dialog_new ("打开文件",
                                          GTK_WINDOW(s->window),
                                          GTK_FILE_CHOOSER_ACTION_OPEN,
                                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                          GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                          NULL);
    g_signal_connect(G_OBJECT(dialog),"destroy",G_CALLBACK(destroy_widget),dialog);
    flag=gtk_dialog_run(GTK_DIALOG (dialog));
    if (flag == GTK_RESPONSE_ACCEPT)
    {
        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        s->teacherinfo_file=(char*)malloc(strlen(filename)+1);
        strcpy(s->teacherinfo_file,filename);
        temp=(char*)malloc(strlen(filename)+1);
        strcpy(temp,filename);
        s->teacherwork_file=(char*)malloc(strlen(temp)+5);
        strcpy(s->teacherwork_file,temp);
        strcat(s->teacherwork_file,"work");
        s->teachwork_file=(char*)malloc(strlen(temp)+10);
        strcpy(s->teachwork_file,temp);
        strcat(s->teachwork_file,"workteach");
        open_file(s);
        g_free (filename);
        g_free (temp);
        gtk_widget_destroy(dialog);
    }
    else if(flag == GTK_RESPONSE_CANCEL)
        gtk_widget_destroy(dialog);

}

//打开函数
void open_file(struct file*s)
{
    FILE*in1,*in2,*in3;
    struct teacherinfo*hp1,*hp;
    struct teacherwork*hp2,*hp_2;
    struct teachwork*hp3,*hp_3;

    head=NULL;

    if((in1=fopen(s->teacherinfo_file,"rb"))==NULL)
        exit(-1);
    if((in2=fopen(s->teacherwork_file,"rb"))==NULL)
        exit(-1);
    if((in3=fopen(s->teachwork_file,"rb"))==NULL)
        exit(-1);
    while(!feof(in1))
    {
        hp1=(struct teacherinfo*)malloc(sizeof(struct teacherinfo));
        fread(hp1,sizeof(struct teacherinfo),1,in1);
        if(!feof(in1))
        {
            hp1->p1=NULL;
            hp1->p2=NULL;
            if(head==NULL)
                head=hp1;
            else
            {
                hp=head;
                while((hp->p2)!=NULL)
                    hp=hp->p2;
                hp->p2=hp1;
            }
        }
    }
    hp1=head;
    while(!feof(in2))
    {
        hp2=(struct teacherwork*)malloc(sizeof(struct teacherwork));
        fread(hp2,sizeof(struct teacherwork),1,in2);
        if(!feof(in2))
        {
            while(hp1!=NULL)
            {
                if(!strcmp(hp1->id,hp2->id))
                {
                    hp2->p2=NULL;
                    hp2->p1=NULL;
                    if(hp1->p1==NULL)
                        hp1->p1=hp2;
                    else
                    {
                        hp_2=hp1->p1;
                        while((hp_2->p2)!=NULL)
                            hp_2=hp_2->p2;
                        hp_2->p2=hp2;
                    }
                    break;
                }
                else
                    hp1=hp1->p2;
            }
        }
    }
    hp1=head;
    while(!feof(in3))
    {
        hp3=(struct teachwork*)malloc(sizeof(struct teachwork));
        fread(hp3,sizeof(struct teachwork),1,in3);
        if(!feof(in3))
        {
            while(hp1!=NULL)
            {
                if(!strcmp(hp1->id,hp3->id))
                {
                    hp2=hp1->p1;
                    while(hp2!=NULL)
                    {
                        if(!strcmp(hp2->year,hp3->year))
                        {
                            hp3->p1=NULL;
                            if(hp2->p1==NULL)
                                hp2->p1=hp3;
                            else
                            {
                                hp_3=hp2->p1;
                                while((hp_3->p1)!=NULL)
                                    hp_3=hp_3->p1;
                                hp_3->p1=hp3;
                            }
                            break;
                        }
                        else
                            hp2=hp2->p2;
                    }
                    break;
                }
                else
                    hp1=hp1->p2;
            }
        }
    }
    gtk_widget_show(s->list1);
    gtk_widget_set_sensitive(s->button,TRUE);
    hp1=head;
    while(hp1!=NULL)
    {
        list_data_add1(s->module,hp1);
        hp1=hp1->p2;
    }

}

//按姓名查询
void find_name(GtkWidget*menu,struct myfind*f)
{
    GtkWidget*window;
    GtkWidget*vbox;
    GtkWidget*hbox;
    GtkWidget*button;
    GtkWidget*label;
    GtkWidget*entry;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"按姓名查询");
    gtk_window_resize(GTK_WINDOW(window),280,120);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("姓名: ");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);
    f->entry=entry;
    f->window=window;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(find_name_confirm),f);
    gtk_widget_show(button);
    button=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);


}

//姓名查询确定按钮
void find_name_confirm(GtkWidget*button,struct myfind*f)
{
    GtkWidget*window;
    GtkWidget*messagedialog;
    GtkWidget*view;
    GtkWidget*vbox;
    GtkWidget*hbox;
    GtkWidget*button1;
    GtkTreeModel*store;
    GtkTreeSelection*select;
    GtkWidget *button2;
    GtkWidget *scrollwindow;
    GtkWidget *button3;
    GtkWidget *button4;

    gint flag;
    gint num;
    gchar name[30];
    struct teacherinfo*hp;
    struct teacherinfo*headp[100];

    for(num=0; num<100; num++)
        headp[num]=NULL;
    num=0;
    hp=head;
    strcpy(name,gtk_entry_get_text(GTK_ENTRY(f->entry)));
    while(hp!=NULL)
    {
        if((strcmp(hp->name,name))==0)
        {
            headp[num++]=hp;
            hp=hp->p2;
        }
        else
            hp=hp->p2;
    }

    num=0;
    if(headp[num]==NULL)
    {
        messagedialog=gtk_message_dialog_new(GTK_WINDOW(f->window),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"查无此人");
        flag=(gtk_dialog_run(GTK_DIALOG(messagedialog)));
        if(flag==GTK_RESPONSE_CLOSE)
        {
            gtk_widget_destroy(f->window);
        }
        else if(flag==GTK_RESPONSE_DELETE_EVENT)
        {
            gtk_widget_destroy(f->window);
        }
    }
    else
    {
        window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
        gtk_window_set_title(GTK_WINDOW(window),"查询结果");
        gtk_window_resize(GTK_WINDOW(window),500,200);
        gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

        vbox=gtk_vbox_new(FALSE,0);
        gtk_container_add(GTK_CONTAINER(window),vbox);

        scrollwindow=gtk_scrolled_window_new(NULL,NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start(GTK_BOX(vbox),scrollwindow,TRUE,TRUE,0);
        gtk_widget_show(scrollwindow);

        view=gtk_tree_view_new();
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwindow),view);
        arrange_treelist1(view);
        store=creat_module2();
        gtk_tree_view_set_model(GTK_TREE_VIEW(view),store);
        while(headp[num]!=NULL)
        {
            list_data_add1(store,headp[num]);
            num++;
        }
        select = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
        gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
        gtk_widget_show(view);
        find_l1.select=select;
        e0.module=store;
        e0.select=select;
        e0.module2=f->module;
        e0.treeview=f->treeview;
        md0.module2=f->module;
        md0.treeview=f->treeview;
        md0.module=store;
        md0.select=select;
        mi0.module2=f->module;
        mi0.treeview=f->treeview;
        mi0.module1=store;
        mi0.select=select;

        hbox=gtk_hbox_new(FALSE,0);
        gtk_box_pack_end(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
        button1=gtk_button_new_with_label(" 教师工作量 ");
        g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(list1_teacher_work),&find_l1);
        gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button1,FALSE);
        gtk_widget_show(button1);

        button2=gtk_button_new_with_label("    修改    ");
        gtk_box_pack_start(GTK_BOX(hbox),button2,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button2,FALSE);
        gtk_widget_show(button2);
        g_signal_connect(G_OBJECT(button2),"clicked",G_CALLBACK(edit_teacherinfo),&e0);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button2);

        button3=gtk_button_new_with_label("    删除    ");
        gtk_box_pack_start(GTK_BOX(hbox),button3,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button3,FALSE);
        gtk_widget_show(button3);
        g_signal_connect(G_OBJECT(button3),"clicked",G_CALLBACK(delete_teacherinfo),&md0);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button3);

        button4=gtk_button_new_with_label("    插入    ");
        gtk_box_pack_start(GTK_BOX(hbox),button4,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button4,FALSE);
        gtk_widget_show(button4);
        g_signal_connect(G_OBJECT(button4),"clicked",G_CALLBACK(insert_teacherinfo),&mi0);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button4);

        gtk_widget_show(hbox);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button1);
        gtk_widget_show(vbox);
        gtk_widget_show(window);

    }

}

//按编号查询
void find_id(GtkWidget*menu,struct myfind*f)
{
    GtkWidget*window;
    GtkWidget*vbox;
    GtkWidget*hbox;
    GtkWidget*button;
    GtkWidget*label;
    GtkWidget*entry;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"按编号查询");
    gtk_window_resize(GTK_WINDOW(window),280,120);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号: ");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);
    f->entry=entry;
    f->window=window;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button=gtk_button_new_from_stock(GTK_STOCK_OK);
    g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(find_id_confirm),f);
    gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,5);
    gtk_widget_show(button);
    button=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);
}

//按编号查询确定按钮
void find_id_confirm(GtkWidget*button,struct myfind*f)
{
    GtkWidget*window;
    GtkWidget*messagedialog;
    GtkWidget*view;
    GtkWidget*vbox;
    GtkWidget*hbox;
    GtkWidget*button1;
    GtkTreeModel*store;
    GtkTreeSelection*select;
    GtkWidget *button2;
    GtkWidget *scrollwindow;
    GtkWidget *button3;
    GtkWidget *button4;

    gint flag;
    gchar id[30];
    struct teacherinfo*hp;

    hp=head;
    strcpy(id,gtk_entry_get_text(GTK_ENTRY(f->entry)));
    while(hp!=NULL)
    {
        if((strcmp(hp->id,id))==0)
            break;
        else
            hp=hp->p2;
    }

    if(hp==NULL)
    {
        messagedialog=gtk_message_dialog_new(GTK_WINDOW(f->window),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"查无此人");
        flag=(gtk_dialog_run(GTK_DIALOG(messagedialog)));
        if(flag==GTK_RESPONSE_CLOSE)
        {
            gtk_widget_destroy(f->window);
        }
        else if(flag==GTK_RESPONSE_DELETE_EVENT)
        {
            gtk_widget_destroy(f->window);
        }
    }
    else
    {
        window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
        gtk_window_set_title(GTK_WINDOW(window),"查询结果");
        gtk_window_resize(GTK_WINDOW(window),500,200);
        gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

        vbox=gtk_vbox_new(FALSE,0);
        gtk_container_add(GTK_CONTAINER(window),vbox);

        scrollwindow=gtk_scrolled_window_new(NULL,NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start(GTK_BOX(vbox),scrollwindow,TRUE,TRUE,0);
        gtk_widget_show(scrollwindow);

        view=gtk_tree_view_new();
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwindow),view);
        arrange_treelist1(view);
        store=creat_module2();
        gtk_tree_view_set_model(GTK_TREE_VIEW(view),store);
        list_data_add1(store,hp);
        select = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
        gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
        gtk_widget_show(view);
        find_l1.select=select;
        e0.module=store;
        e0.select=select;
        e0.module2=f->module;
        e0.treeview=f->treeview;
        md0.module2=f->module;
        md0.treeview=f->treeview;
        md0.module=store;
        md0.select=select;
        mi0.module2=f->module;
        mi0.treeview=f->treeview;
        mi0.module1=store;
        mi0.select=select;

        hbox=gtk_hbox_new(FALSE,0);
        gtk_box_pack_end(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
        button1=gtk_button_new_with_label(" 教师工作量 ");
        g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(list1_teacher_work),&find_l1);
        gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button1,FALSE);
        gtk_widget_show(button1);

        button2=gtk_button_new_with_label("    修改    ");
        gtk_box_pack_start(GTK_BOX(hbox),button2,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button2,FALSE);
        gtk_widget_show(button2);
        g_signal_connect(G_OBJECT(button2),"clicked",G_CALLBACK(edit_teacherinfo),&e0);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button2);

        button3=gtk_button_new_with_label("    删除    ");
        gtk_box_pack_start(GTK_BOX(hbox),button3,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button3,FALSE);
        gtk_widget_show(button3);
        g_signal_connect(G_OBJECT(button3),"clicked",G_CALLBACK(delete_teacherinfo),&md0);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button3);

        button4=gtk_button_new_with_label("    插入    ");
        gtk_box_pack_start(GTK_BOX(hbox),button4,FALSE,FALSE,5);
        gtk_widget_set_sensitive(button4,FALSE);
        gtk_widget_show(button4);
        g_signal_connect(G_OBJECT(button4),"clicked",G_CALLBACK(insert_teacherinfo),&mi0);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button4);


        gtk_widget_show(hbox);
        g_signal_connect(G_OBJECT(select),"changed",G_CALLBACK(teacher_work),button1);
        gtk_widget_show(vbox);
        gtk_widget_show(window);

    }

}

//添加数据到总科研经费
void model_data_new1(GtkTreeModel*store,struct money*m)
{
    GtkTreeIter iter;

    gtk_list_store_append(GTK_LIST_STORE(store), &iter);
    gtk_list_store_set(GTK_LIST_STORE(store),&iter,NAME,m->name,CONTENT,m->jingfei,-1);

}

//创建总科研经费统计模型
GtkTreeModel* create_count_module1(void)
{
    GtkListStore  *store;
    store = gtk_list_store_new (N_COLUMN,
                                G_TYPE_STRING,G_TYPE_DOUBLE);
    return GTK_TREE_MODEL(store);

}

//添加column到总科研经费统计
void arrange_count_view1(GtkWidget* view)
{
    GtkCellRenderer* renderer;

    // col 1: name
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(view), -1, "姓名               ", renderer, "text", NAME, NULL);

    // col 2: content
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(view), -1, "总科研经费", renderer, "text", CONTENT, NULL);

}

//统计总科研经费
void count_money(GtkWidget*menu,struct money*m)
{
    GtkWidget *window;
    GtkWidget *view;
    GtkTreeModel *store;

    struct teacherinfo*hp=head;
    struct teacherwork*p1;
    struct money*p,*headp=NULL,*temp;
    double total,t_total;
    int jishu=0,i;
    char name[30];

    while(hp!=NULL)
    {
        p=(struct money*)malloc(sizeof(struct money));
        jishu++;
        strcpy(p->name,hp->name);
        p1=hp->p1;
        total=0;
        while(p1!=NULL)
        {
            total+=(atof(p1->keyan));
            p1=p1->p2;
        }
        p->jingfei=total;
        p->next=NULL;
        if(headp==NULL)
            headp=p;
        else
        {
            temp=headp;
            while(temp->next!=NULL)
            {
                temp=temp->next;
            }
            temp->next=p;
        }
        hp=hp->p2;
    }

    //排序
    for(i=0; i<jishu; i++)
    {
        for(temp=headp; temp->next!=NULL;)
        {
            strcpy(name,temp->name);
            t_total=temp->jingfei;
            if(temp->jingfei<temp->next->jingfei)
            {
                strcpy(temp->name,temp->next->name);
                temp->jingfei=temp->next->jingfei;
                strcpy(temp->next->name,name);
                temp->next->jingfei=t_total;
            }
            temp=temp->next;
        }
    }

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"科研总经费");
    gtk_window_resize(GTK_WINDOW(window),300,350);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

    view = gtk_tree_view_new();
    gtk_container_add( GTK_CONTAINER(window), view);
    arrange_count_view1(view);
    store = create_count_module1();
    gtk_tree_view_set_model ( GTK_TREE_VIEW(view),  store);
    p=headp;
    while(p!=NULL)
    {
        model_data_new1(store,p);
        p=p->next;
    }
    gtk_widget_show(view);
    gtk_widget_show(window);

}

//添加数据到教学总学时
void model_data_new2(GtkTreeModel*store,struct mytime*m)
{
    GtkTreeIter iter;

    gtk_list_store_append(GTK_LIST_STORE(store), &iter);
    gtk_list_store_set(GTK_LIST_STORE(store),&iter,NAME,m->name,CONTENT,m->time,-1);
}

//创建教学总学时统计模型
GtkTreeModel* create_count_module2(void)
{
    GtkListStore  *store;
    store = gtk_list_store_new (N_COLUMN,
                                G_TYPE_STRING,G_TYPE_INT);
    return GTK_TREE_MODEL(store);
}

//添加column到教学总学时
void arrange_count_view2(GtkWidget* view)
{
    GtkCellRenderer* renderer;

    // col 1: name
    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(view), -1, "姓名               ", renderer, "text", NAME, NULL);

    // col 2: content
    gtk_tree_view_insert_column_with_attributes(
        GTK_TREE_VIEW(view), -1, "教学总学时", renderer, "text", CONTENT, NULL);
}

// 输入年份
void input_year(GtkWidget*menu,struct mytime*m)
{
    GtkWidget*window;
    GtkWidget*entry;
    GtkWidget*label;
    GtkWidget*button1;
    GtkWidget*vbox;
    GtkWidget*hbox;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"输入年份");
    gtk_window_resize(GTK_WINDOW(window),200,100);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);
    m->window=window;

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    m->entry=entry;
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(count_mytime),m);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);


}

//统计教学总学时
void count_mytime(GtkWidget*menu,struct mytime*m)
{
    GtkWidget *window;
    GtkWidget *view;
    GtkTreeModel *store;
    GtkWidget *messagedialog;

    struct teacherinfo*hp=head;
    struct teacherwork*p1;
    struct teachwork*p2;
    struct mytime*p,*headp=NULL,*temp;
    double total,t_total;
    int jishu=0,i;
    char name[30];
    gint flag;

    while(hp!=NULL)
    {
        p=(struct mytime*)malloc(sizeof(struct mytime));
        jishu++;
        strcpy(p->name,hp->name);
        p1=hp->p1;
        total=0;
        while(p1!=NULL)
        {
            if(!strcmp(p1->year,gtk_entry_get_text(GTK_ENTRY(m->entry))))
            {
                p2=p1->p1;
                while(p2!=NULL)
                {
                    total=total+(atoi(p2->shiyan))+(atoi(p2->shouke));
                    p2=p2->p1;
                }
                break;
            }
            else
                p1=p1->p2;
        }
        if(total==0)
        {
            messagedialog=gtk_message_dialog_new(GTK_WINDOW(m->window),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"无此年份");
            flag=gtk_dialog_run(GTK_DIALOG(messagedialog));
            if(flag==GTK_RESPONSE_CLOSE)
                gtk_widget_destroy(m->window);
            else if(flag==GTK_RESPONSE_DELETE_EVENT)
                gtk_widget_destroy(m->window);
            return;
        }
        else
        {
            p->time=total;
            p->next=NULL;
        }
        if(headp==NULL)
            headp=p;
        else
        {
            temp=headp;
            while(temp->next!=NULL)
            {
                temp=temp->next;
            }
            temp->next=p;
        }
        hp=hp->p2;
    }

    //排序
    for(i=0; i<jishu; i++)
    {
        for(temp=headp; temp->next!=NULL;)
        {
            strcpy(name,temp->name);
            t_total=temp->time;
            if(temp->time<temp->next->time)
            {
                strcpy(temp->name,temp->next->name);
                temp->time=temp->next->time;
                strcpy(temp->next->name,name);
                temp->next->time=t_total;
            }
            temp=temp->next;
        }
    }

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教学总学时");
    gtk_window_resize(GTK_WINDOW(window),300,350);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

    view = gtk_tree_view_new();
    gtk_container_add( GTK_CONTAINER(window), view);
    arrange_count_view2(view);
    store = create_count_module2();
    gtk_tree_view_set_model ( GTK_TREE_VIEW(view),  store);
    p=headp;
    while(p!=NULL)
    {
        model_data_new2(store,p);
        p=p->next;
    }
    gtk_widget_show(view);
    gtk_widget_show(window);
    gtk_widget_destroy(m->window);
}

//输入年份及达标线
void input_content(GtkWidget*menu,struct mytime*m)
{
    GtkWidget*window;
    GtkWidget*entry1;
    GtkWidget*entry2;
    GtkWidget*label;
    GtkWidget*button1;
    GtkWidget*vbox;
    GtkWidget*hbox;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"输入框");
    gtk_window_resize(GTK_WINDOW(window),200,150);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);
    m->window=window;

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    m->entry=entry1;
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("达标线:");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    m->entry2=entry2;
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(count_unqulified),m);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);
}

//统计教学工作量未达标
void count_unqulified(GtkWidget*button,struct mytime*m)
{
    GtkWidget *window;
    GtkWidget *view;
    GtkTreeModel *store;
    GtkWidget*messagedialog;

    struct teacherinfo*hp=head;
    struct teacherwork*p1;
    struct teachwork*p2;
    int total;
    gchar time[8];
    int time2;
    gint flag;

    strcpy(time,gtk_entry_get_text(GTK_ENTRY(m->entry2)));
    time2=atoi(time);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教学工作量未达标");
    gtk_window_resize(GTK_WINDOW(window),508,410);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

    view = gtk_tree_view_new();
    gtk_container_add( GTK_CONTAINER(window), view);
    arrange_treelist1(view);
    store = creat_module1();
    gtk_tree_view_set_model ( GTK_TREE_VIEW(view),  store);

    while(hp!=NULL)
    {
        p1=hp->p1;
        total=0;
        while(p1!=NULL)
        {
            if(!strcmp(p1->year,gtk_entry_get_text(GTK_ENTRY(m->entry))))
            {
                p2=p1->p1;
                while(p2!=NULL)
                {
                    total=total+(atoi(p2->shiyan))+(atoi(p2->shouke));
                    p2=p2->p1;
                }
                break;
            }
            else
                p1=p1->p2;
        }
        if(total==0)
        {
            messagedialog=gtk_message_dialog_new(GTK_WINDOW(m->window),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,"无此年份");
            flag=gtk_dialog_run(GTK_DIALOG(messagedialog));
            if(flag==GTK_RESPONSE_CLOSE)
                gtk_widget_destroy(m->window);
            else if(flag==GTK_RESPONSE_DELETE_EVENT)
                gtk_widget_destroy(m->window);
            return;
        }
        else if(total<time2)
            list_data_add1(store,hp);
        hp=hp->p2;
    }


    gtk_widget_show(view);
    gtk_widget_show(window);
    gtk_widget_destroy(m->window);

}

//修改按钮1
void edit_teacherinfo(GtkWidget*button,struct edit*e)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *button1;
    GtkTreeModel *model;
    gchar *id;

    struct teacherinfo*hp=head;

    if (gtk_tree_selection_get_selected (e->select, &model, &edit_teacherinfo_iter))
        gtk_tree_model_get (model, &edit_teacherinfo_iter, ID1, &id, -1);
    while(hp!=NULL)
    {
        if(!strcmp(hp->id,id))
            break;
        else
            hp=hp->p2;
    }
    e->iter=&edit_teacherinfo_iter;
    e->p=hp;
    g_free(id);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师基本信息");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);
    e->window=window;

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),hp->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("姓名    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry1),hp->name);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("单位    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry2),hp->workplace);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("职称    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry3),hp->duty);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    e->entry=entry;
    e->entry1=entry1;
    e->entry2=entry2;
    e->entry3=entry3;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(edit_confirm1),e);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);

}

//确认修改按钮1
void edit_confirm1(GtkWidget*button,struct edit*e)
{
    struct teacherinfo*hp1;

    strcpy(e->p->id,gtk_entry_get_text(GTK_ENTRY(e->entry)));
    strcpy(e->p->name,gtk_entry_get_text(GTK_ENTRY(e->entry1)));
    strcpy(e->p->workplace,gtk_entry_get_text(GTK_ENTRY(e->entry2)));
    strcpy(e->p->duty,gtk_entry_get_text(GTK_ENTRY(e->entry3)));

    gtk_list_store_set(GTK_LIST_STORE(e->module),&edit_teacherinfo_iter,ID1,e->p->id,NAME1,e->p->name,WORK1,e->p->workplace,DUTY1,e->p->duty,-1);
    if(e->module2!=NULL)
    {
        hp1=head;
        gtk_list_store_clear(GTK_LIST_STORE(module1));
        module1=creat_module1();
        gtk_tree_view_set_model(GTK_TREE_VIEW(treelist1),module1);
        e_0.module=module1;
        while(hp1!=NULL)
        {
            list_data_add1(module1,hp1);
            hp1=hp1->p2;
        }
    }
    gtk_widget_destroy(e->window);

}

//修改按钮2
void edit_teacherwork(GtkWidget*button,struct edit*e)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *button1;
    GtkTreeModel *model;
    gchar *id;
    gchar *year;

    struct teacherinfo*hp=head;
    struct teacherwork*p;

    if (gtk_tree_selection_get_selected (e->select, &model, &edit_teacherinfo_iter))
        gtk_tree_model_get (model, &edit_teacherinfo_iter, ID1, &id, YEAR2, &year, -1);
    while(hp!=NULL)
    {
        if(!strcmp(hp->id,id))
        {
            p=hp->p1;
            while(p!=NULL)
            {
                if(!strcmp(p->year,year))
                    break;
                else
                    p=p->p2;
            }
            break;
        }
        else
            hp=hp->p2;
    }
    e->iter=&edit_teacherinfo_iter;
    e->p=hp;
    e->p1=p;
    g_free(id);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师基本信息");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);
    e->window=window;

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID              :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),p->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份                 :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry1),p->year);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("科研工作量(万元):");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry2),p->keyan);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("指导毕设(人)      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry3),p->bishe);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("指导硕/博(人)     :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry4=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry4),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry4,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry4),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry4),p->shuobo);
    gtk_widget_show(entry4);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("总分(分)            :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry5=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry5),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry5,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry5),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry5),p->zongfen);
    gtk_widget_show(entry5);
    gtk_widget_show(hbox);

    e->entry=entry;
    e->entry1=entry1;
    e->entry2=entry2;
    e->entry3=entry3;
    e->entry4=entry4;
    e->entry5=entry5;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(edit_confirm2),e);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);

}

//确认修改按钮2
void edit_confirm2(GtkWidget*button,struct edit*e)
{
    strcpy(e->p1->id,gtk_entry_get_text(GTK_ENTRY(e->entry)));
    strcpy(e->p1->year,gtk_entry_get_text(GTK_ENTRY(e->entry1)));
    strcpy(e->p1->keyan,gtk_entry_get_text(GTK_ENTRY(e->entry2)));
    strcpy(e->p1->bishe,gtk_entry_get_text(GTK_ENTRY(e->entry3)));
    strcpy(e->p1->shuobo,gtk_entry_get_text(GTK_ENTRY(e->entry4)));
    strcpy(e->p1->zongfen,gtk_entry_get_text(GTK_ENTRY(e->entry5)));

    gtk_list_store_set(GTK_LIST_STORE(e->module),&edit_teacherinfo_iter,ID2,e->p1->id,YEAR2,e->p1->year,KEYAN2,e->p1->keyan,BISHE2,e->p1->bishe,SHUO_BO2,e->p1->shuobo,TOTAL2,e->p1->zongfen,-1);
    gtk_widget_destroy(e->window);

}

//修改按钮3
void edit_teachwork(GtkWidget*button,struct edit*e)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *entry6;
    GtkWidget *button1;
    GtkTreeModel *model;
    gchar *id;
    gchar *year;
    gchar *kecheng;

    struct teacherinfo*hp=head;
    struct teacherwork*p;
    struct teachwork*p1;

    if (gtk_tree_selection_get_selected (e->select, &model, &edit_teacherinfo_iter))
        gtk_tree_model_get (model, &edit_teacherinfo_iter, ID1, &id, YEAR2, &year, KECHENG3, &kecheng, -1);
    while(hp!=NULL)
    {
        if(!strcmp(hp->id,id))
        {
            p=hp->p1;
            while(p!=NULL)
            {
                if(!strcmp(p->year,year))
                {
                    p1=p->p1;
                    while(p1!=NULL)
                    {
                        if(!strcmp(p1->kecheng,kecheng))
                            break;
                        else
                            p1=p1->p1;
                    }
                    break;
                }
                else
                    p=p->p2;
            }
            break;
        }
        else
            hp=hp->p2;
    }
    e->iter=&edit_teacherinfo_iter;
    e->p=hp;
    e->p1=p;
    e->p2=p1;
    g_free(id);

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师基本信息");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);
    e->window=window;

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),p1->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份         :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry1),p1->year);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("课程名      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry2),p1->kecheng);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("授课学时   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry3),p1->shouke);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("实验学时   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry4=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry4),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry4,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry4),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry4),p1->shiyan);
    gtk_widget_show(entry4);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("学生人数   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry5=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry5),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry5,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry5),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry5),p1->renshu);
    gtk_widget_show(entry5);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("班级         :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry6=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry6),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry6,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry6),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry6),p1->banji);
    gtk_widget_show(entry6);
    gtk_widget_show(hbox);

    e->entry=entry;
    e->entry1=entry1;
    e->entry2=entry2;
    e->entry3=entry3;
    e->entry4=entry4;
    e->entry5=entry5;
    e->entry6=entry6;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(edit_confirm3),e);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,TRUE,TRUE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);
}

//确认修改按钮3
void edit_confirm3(GtkWidget*button,struct edit*e)
{
    strcpy(e->p2->id,gtk_entry_get_text(GTK_ENTRY(e->entry)));
    strcpy(e->p2->year,gtk_entry_get_text(GTK_ENTRY(e->entry1)));
    strcpy(e->p2->kecheng,gtk_entry_get_text(GTK_ENTRY(e->entry2)));
    strcpy(e->p2->shouke,gtk_entry_get_text(GTK_ENTRY(e->entry3)));
    strcpy(e->p2->shiyan,gtk_entry_get_text(GTK_ENTRY(e->entry4)));
    strcpy(e->p2->renshu,gtk_entry_get_text(GTK_ENTRY(e->entry5)));
    strcpy(e->p2->banji,gtk_entry_get_text(GTK_ENTRY(e->entry6)));

    gtk_list_store_set(GTK_LIST_STORE(e->module),&edit_teacherinfo_iter,ID3,e->p2->id,YEAR3,e->p2->year,KECHENG3,e->p2->kecheng,SHOUKEXUESHI3,e->p2->shouke,SHIYANXUESHI3,e->p2->shiyan,XUESHENGRENSHU3,e->p2->renshu,BANJI3,e->p2->banji,-1);
    gtk_widget_destroy(e->window);
}

//删除按钮1
void delete_teacherinfo(GtkWidget*button,struct mydelete*m)
{
    struct teacherinfo*p1=head,*temp1,*hp1;
    struct teacherwork*p2,*temp2;
    struct teachwork*p3,*temp3;

    GtkTreeIter iter;
    GtkTreeModel *model;
    gchar *id;

    hp1=head;
    if (gtk_tree_selection_get_selected (m->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID1, &id, -1);

    while(p1!=NULL)
    {
        if(!strcmp(p1->id,id))
        {
            if(p1==head)
            {
                head=p1->p2;
                p2=p1->p1;
                while(p2!=NULL)
                {
                    p3=p2->p1;
                    while(p3!=NULL)
                    {
                        temp3=p3->p1;
                        free(p3);
                        p3=temp3;
                    }
                    temp2=p2->p2;
                    free(p2);
                    p2=temp2;
                }
                free(p1);
            }
            else
            {
                temp1=head;
                while(temp1->p2!=p1)
                    temp1=temp1->p2;
                temp1->p2=p1->p2;
                p2=p1->p1;
                while(p2!=NULL)
                {
                    p3=p2->p1;
                    while(p3!=NULL)
                    {
                        temp3=p3->p1;
                        free(p3);
                        p3=temp3;
                    }
                    temp2=p2->p2;
                    free(p2);
                    p2=temp2;
                }
                free(p1);
            }
            break;
        }
        else
            p1=p1->p2;
    }
    if(m->module2==NULL)
        gtk_list_store_remove(GTK_LIST_STORE(m->module),&iter);
    else
    {
        gtk_list_store_remove(GTK_LIST_STORE(m->module),&iter);
        gtk_list_store_clear(GTK_LIST_STORE(module1));
        module1=creat_module1();
        gtk_tree_view_set_model(GTK_TREE_VIEW(treelist1),module1);
        md.module=module1;
        while(hp1!=NULL)
        {
            list_data_add1(module1,hp1);
            hp1=hp1->p2;
        }
    }

}

//删除按钮2
void delete_teacherwork(GtkWidget*button,struct mydelete*m)
{
    struct teacherinfo*p1=head;
    struct teacherwork*p2,*temp2;
    struct teachwork*p3,*temp3;

    GtkTreeIter iter;
    GtkTreeModel *model;
    gchar *id;
    gchar *year;

    if (gtk_tree_selection_get_selected (m->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID2, &id, YEAR2, &year, -1);
    while(p1!=NULL)
    {
        if(!strcmp(p1->id,id))
        {
            p2=p1->p1;
            while(p2!=NULL)
            {
                if(!strcmp(p2->year,year))
                {
                    if(p1->p1==p2)
                    {
                        p1->p1=p2->p2;
                        p3=p2->p1;
                        while(p3!=NULL)
                        {
                            temp3=p3->p1;
                            free(p3);
                            p3=temp3;
                        }
                        free(p2);
                    }
                    else
                    {
                        temp2=p1->p1;
                        while(temp2->p2!=p2)
                            temp2=temp2->p2;
                        temp2->p2=p2->p2;
                        p3=p2->p1;
                        while(p3!=NULL)
                        {
                            temp3=p3->p1;
                            free(p3);
                            p3=temp3;
                        }
                        free(p2);
                    }
                    break;
                }
                else
                    p2=p2->p2;
            }
            break;
        }
        else
            p1=p1->p2;
    }
    gtk_list_store_remove(GTK_LIST_STORE(m->module),&iter);
}

//删除按钮3
void delete_teachwork(GtkWidget*button,struct mydelete*m)
{
    GtkTreeIter iter;
    GtkTreeModel *model;
    gchar *id;
    gchar *year;
    gchar *kecheng;

    struct teacherinfo*p1=head;
    struct teacherwork*p2;
    struct teachwork*p3,*temp3;

    if (gtk_tree_selection_get_selected (m->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID3, &id, YEAR3, &year, KECHENG3, &kecheng, -1);
    while(p1!=NULL)
    {
        if(!strcmp(p1->id,id))
        {
            p2=p1->p1;
            while(p2!=NULL)
            {
                if(!strcmp(p2->year,year))
                {
                    p3=p2->p1;
                    while(p3!=NULL)
                    {
                        if(!strcmp(p3->kecheng,kecheng))
                        {
                            if(p3==p2->p1)
                            {
                                p2->p1=p3->p1;
                                free(p3);
                            }
                            else
                            {
                                temp3=p2->p1;
                                while(temp3->p1!=p3)
                                    temp3=temp3->p1;
                                temp3->p1=p3->p1;
                                free(p3);
                            }
                            break;
                        }
                        else
                            p3=p3->p1;
                    }
                    break;
                }
                else
                    p2=p2->p2;
            }
            break;
        }
        p1=p1->p2;
    }
    gtk_list_store_remove(GTK_LIST_STORE(m->module),&iter);
}

//插入按钮1
void insert_teacherinfo(GtkWidget*button,struct myinsert*m)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *button1;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师基本信息");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("姓名    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("单位    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("职称    :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);


    m->entry=entry;
    m->entry1=entry1;
    m->entry2=entry2;
    m->entry3=entry3;
    m->window=window;
    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(insert_confirm1),m);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);

}

//插入按钮确认1
void insert_confirm1(GtkWidget*button,struct myinsert*m)
{
    struct teacherinfo*p,*hp=head,*temp,*hp1;

    GtkTreeIter iter;
    GtkTreeIter iter2;
    GtkTreeModel *model;
    gchar *id;

    hp1=head;

    if (gtk_tree_selection_get_selected (m->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID1, &id, -1);

    p=(struct teacherinfo*)malloc(sizeof(struct teacherinfo));
    strcpy(p->id,gtk_entry_get_text(GTK_ENTRY(m->entry)));
    strcpy(p->name,gtk_entry_get_text(GTK_ENTRY(m->entry1)));
    strcpy(p->workplace,gtk_entry_get_text(GTK_ENTRY(m->entry2)));
    strcpy(p->duty,gtk_entry_get_text(GTK_ENTRY(m->entry3)));
    p->p1=NULL;
    p->p2=NULL;

    while(hp!=NULL)
    {
        if(!strcmp(hp->id,id))
        {
            temp=hp->p2;
            hp->p2=p;
            p->p2=temp;
            if(m->module2==NULL)
            {
                gtk_list_store_insert_after(GTK_LIST_STORE(m->module1),&iter2,&iter);
                gtk_list_store_set(GTK_LIST_STORE(m->module1),&iter2,ID1,p->id,NAME1,p->name,WORK1,p->workplace,DUTY1,p->duty,-1);
            }
            else
            {
                gtk_list_store_insert_after(GTK_LIST_STORE(m->module1),&iter2,&iter);
                gtk_list_store_set(GTK_LIST_STORE(m->module1),&iter2,ID1,p->id,NAME1,p->name,WORK1,p->workplace,DUTY1,p->duty,-1);
                gtk_list_store_clear(GTK_LIST_STORE(module1));
                module1=creat_module1();
                gtk_tree_view_set_model(GTK_TREE_VIEW(treelist1),module1);
                mi.module1=module1;
                while(hp1!=NULL)
                {
                    list_data_add1(module1,hp1);
                    hp1=hp1->p2;
                }
            }
            break;
        }
        else
            hp=hp->p2;
    }
    g_free(id);
    gtk_widget_destroy(m->window);
}

//插入按钮2
void insert_teacherwork(GtkWidget*button,struct myinsert*m)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *button1;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教师工作量");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);

    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID              :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),m->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份                 :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("科研工作量(万元):");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("指导毕设(人)      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("指导硕/博(人)     :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry4=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry4),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry4,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry4),TRUE);
    gtk_widget_show(entry4);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("总分(分)            :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry5=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry5),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry5,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry5),TRUE);
    gtk_widget_show(entry5);
    gtk_widget_show(hbox);

    m->entry=entry;
    m->entry1=entry1;
    m->entry2=entry2;
    m->entry3=entry3;
    m->entry4=entry4;
    m->entry5=entry5;
    m->window=window;
    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(insert_confirm2),m);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);
}

//插入按钮确认2
void insert_confirm2(GtkWidget*button,struct myinsert*m)
{
    GtkTreeIter iter;
    GtkTreeIter iter2;
    GtkTreeModel *model;
    gchar *id;
    gchar *year;

    struct teacherinfo*hp=head;
    struct teacherwork*p,*p1,*temp;

    if (gtk_tree_selection_get_selected (m->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID2, &id, YEAR2, &year, -1);

    p=(struct teacherwork*)malloc(sizeof(struct teacherwork));
    strcpy(p->id,gtk_entry_get_text(GTK_ENTRY(m->entry)));
    strcpy(p->year,gtk_entry_get_text(GTK_ENTRY(m->entry1)));
    strcpy(p->keyan,gtk_entry_get_text(GTK_ENTRY(m->entry2)));
    strcpy(p->bishe,gtk_entry_get_text(GTK_ENTRY(m->entry3)));
    strcpy(p->shuobo,gtk_entry_get_text(GTK_ENTRY(m->entry4)));
    strcpy(p->zongfen,gtk_entry_get_text(GTK_ENTRY(m->entry5)));
    p->p1=NULL;
    p->p2=NULL;

    while(hp!=NULL)
    {
        if(!strcmp(hp->id,id))
        {
            p1=hp->p1;
            while(p1!=NULL)
            {
                if(!strcmp(p1->year,year))
                {
                    temp=p1->p2;
                    p1->p2=p;
                    p->p2=temp;
                    gtk_list_store_insert_after(GTK_LIST_STORE(m->module1),&iter2,&iter);
                    gtk_list_store_set(GTK_LIST_STORE(m->module1),&iter2,ID2,p->id,YEAR2,p->year,KEYAN2,p->keyan,BISHE2,p->bishe,SHUO_BO2,p->shuobo,TOTAL2,p->zongfen,-1);
                    break;
                }
                else
                    p1=p1->p2;
            }
            break;
        }
        else
            hp=hp->p2;
    }
    g_free(id);
    g_free(year);
    gtk_widget_destroy(m->window);
}

//插入按钮3
void insert_teachwork(GtkWidget*button,struct myinsert*m)
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *entry1;
    GtkWidget *entry2;
    GtkWidget *entry3;
    GtkWidget *entry4;
    GtkWidget *entry5;
    GtkWidget *entry6;
    GtkWidget *button1;

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(destroy_widget),window);
    gtk_window_set_title(GTK_WINDOW(window),"教学工作");
    gtk_window_resize(GTK_WINDOW(window),200,200);
    gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window),20);
    gtk_widget_show(window);


    vbox=gtk_vbox_new(FALSE,0);
    gtk_container_add(GTK_CONTAINER(window),vbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("编号ID      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry),m->id);
    gtk_widget_show(entry);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("年份         :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry1=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry1),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry1,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry1),TRUE);
    gtk_entry_set_text(GTK_ENTRY(entry1),m->year);
    gtk_widget_show(entry1);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("课程名      :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry2=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry2),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry2,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry2),TRUE);
    gtk_widget_show(entry2);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("授课学时   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry3=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry3),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry3,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry3),TRUE);
    gtk_widget_show(entry3);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("实验学时   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry4=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry4),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry4,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry4),TRUE);
    gtk_widget_show(entry4);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("学生人数   :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry5=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry5),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry5,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry5),TRUE);
    gtk_widget_show(entry5);
    gtk_widget_show(hbox);

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    label=gtk_label_new("班级         :");
    gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,5);
    gtk_widget_show(label);
    entry6=gtk_entry_new();
    gtk_entry_set_visibility(GTK_ENTRY(entry6),TRUE);
    gtk_box_pack_start(GTK_BOX(hbox),entry6,FALSE,FALSE,5);
    gtk_editable_set_editable (GTK_EDITABLE(entry6),TRUE);
    gtk_widget_show(entry6);
    gtk_widget_show(hbox);

    m->entry=entry;
    m->entry1=entry1;
    m->entry2=entry2;
    m->entry3=entry3;
    m->entry4=entry4;
    m->entry5=entry5;
    m->entry6=entry6;
    m->window=window;

    hbox=gtk_hbox_new(FALSE,0);
    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
    button1=gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(insert_confirm3),m);
    gtk_widget_show(button1);
    button1=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_start(GTK_BOX(hbox),button1,FALSE,FALSE,5);
    g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroy_widget),window);
    gtk_widget_show(button1);
    gtk_widget_show(hbox);

    gtk_widget_show(vbox);
}

//插入按钮确认3
void insert_confirm3(GtkWidget*button,struct myinsert*m)
{
    GtkTreeIter iter;
    GtkTreeIter iter2;
    GtkTreeModel *model;
    gchar *id;
    gchar *year;
    gchar *kecheng;

    struct teacherinfo*p1=head;
    struct teacherwork*p2;
    struct teachwork*p,*p3,*temp;

    if (gtk_tree_selection_get_selected (m->select, &model, &iter))
        gtk_tree_model_get (model, &iter, ID3, &id, YEAR3, &year, KECHENG3, &kecheng, -1);

    p=(struct teachwork*)malloc(sizeof(struct teachwork));
    strcpy(p->id,gtk_entry_get_text(GTK_ENTRY(m->entry)));
    strcpy(p->year,gtk_entry_get_text(GTK_ENTRY(m->entry1)));
    strcpy(p->kecheng,gtk_entry_get_text(GTK_ENTRY(m->entry2)));
    strcpy(p->shouke,gtk_entry_get_text(GTK_ENTRY(m->entry3)));
    strcpy(p->shiyan,gtk_entry_get_text(GTK_ENTRY(m->entry4)));
    strcpy(p->renshu,gtk_entry_get_text(GTK_ENTRY(m->entry5)));
    strcpy(p->banji,gtk_entry_get_text(GTK_ENTRY(m->entry6)));
    p->p1=NULL;

    while(p1!=NULL)
    {
        if(!strcmp(p1->id,id))
        {
            p2=p1->p1;
            while(p2!=NULL)
            {
                if(!strcmp(p2->year,year))
                {
                    p3=p2->p1;
                    while(p3!=NULL)
                    {
                        if(!strcmp(p3->year,year))
                        {
                            temp=p3->p1;
                            p3->p1=p;
                            p->p1=temp;
                            gtk_list_store_insert_after(GTK_LIST_STORE(m->module1),&iter2,&iter);
                            gtk_list_store_set(GTK_LIST_STORE(m->module1),&iter2,ID3,p->id,YEAR3,p->year,KECHENG3,p->kecheng,SHOUKEXUESHI3,p->shouke,SHIYANXUESHI3,p->shiyan,XUESHENGRENSHU3,p->renshu,BANJI3,p->banji,-1);
                            break;
                        }
                        else
                            p3=p3->p1;
                    }
                    break;
                }
                else
                    p2=p2->p2;
            }
            break;
        }
        else
            p1=p1->p2;
    }
    g_free(id);
    g_free(year);
    g_free(kecheng);
    gtk_widget_destroy(m->window);
}
